Skip to content

fix(ValidationMessage): only set aria-invalid if danger color - #5149

Merged
eirikbacker merged 11 commits into
mainfrom
docs/validation-message
Aug 17, 2026
Merged

eirikbacker merged 11 commits into
mainfrom
docs/validation-message

Conversation

@Barsnes

@Barsnes Barsnes commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

adds docs about #5140

Checks

@changeset-bot

changeset-bot Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d9e92a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@digdir/designsystemet-web Patch
@digdir/designsystemet-react Patch
@digdir/designsystemet Patch
@digdir/designsystemet-css Patch
@digdir/designsystemet-types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Barsnes
Barsnes marked this pull request as ready for review August 10, 2026 06:41
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployments for this pull request:

storybook - 17. Aug 2026 - 11:47

www - 17. Aug 2026 - 11:49

@eirikbacker eirikbacker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer a fix of the logic rather than docs for a workaround 😌

@eirikbacker
eirikbacker self-requested a review August 14, 2026 05:36
@eirikbacker

Copy link
Copy Markdown
Contributor

Updated here, seems we already had the logic, but did not properly use it 🙈

@eirikbacker
eirikbacker dismissed their stale review August 14, 2026 05:37

Updated code

@eirikbacker eirikbacker changed the title docs(ValidationMessage): add note about field validation in react fix(ValidationMessage): only set aria-invalid if danger color Aug 17, 2026
Comment thread .changeset/old-pillows-hear.md Resolved
Co-authored-by: Michael Marszalek <mimarz@gmail.com>
const isInvalid = (el: Element) => el.getAttribute('data-color') !== 'success';
const isInvalidColor = (el: Element) => {
const color = el.getAttribute('data-color');
return !color || color === 'danger';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be to early for me but is this first check correct? If no data-color is defined, then its an invalid color?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, default color of validation is danger, so no color = danger ☺️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no color is set, every data-field="validation" should make the input invalid

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is how it works now ☺️

@Barsnes Barsnes left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some documentation to field and validationmessage, and I think this is good

@eirikbacker

Copy link
Copy Markdown
Contributor

Add some documentation to field and validationmessage, and I think this is good

Done ☺️

Co-authored-by: Tobias Barsnes <tobiasbarsnes@gmail.com>
@eirikbacker
eirikbacker merged commit 8208147 into main Aug 17, 2026
19 checks passed
@eirikbacker
eirikbacker deleted the docs/validation-message branch August 17, 2026 10:04
@github-actions github-actions Bot mentioned this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants